<template>
  <div>
    <template v-if="!item.children || item.children.length === 0">
      <el-menu-item :index="item.id">
        <i v-if="item.icon" :class="item.icon"></i>
        {{ item.key }}
      </el-menu-item>
    </template>
    <template v-else>
      <el-submenu :index="item.id">
        <template slot="title">
          <i v-if="item.icon" :class="item.icon"></i>
          {{ item.key }}
        </template>
        <template v-for="(child, index) in item.children">
          <sub-path :key="index" :item="child" />
        </template>
      </el-submenu>
    </template>
  </div>
</template>

<script>
export default {
  name: "SubPath",
  props: {
    item: {
      type: Object,
      default() {
        return {};
      }
    }
  }
};
</script>

<style lang="scss" scoped>
::v-deep .el-menu {
  li {
    background-color: #f5f5f5;
  }
}
</style>
